/*     */ package com.newcrm.webapi;
/*     */ 
/*     */ import com.newcrm.bean.CompanyInfo;
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.CompanyExtManager;
/*     */ import com.newcrm.db.CustomerManager;
/*     */ import com.newcrm.exception.NotFoundException;
/*     */ import com.newcrm.manager.LuceneManager;
/*     */ import com.newcrm.util.ParameterUtil;
/*     */ import com.newcrm.util.Util;
/*     */ import com.newcrm.webapi.sub.ActiveCodeChecker;
/*     */ import com.newcrm.webapi.sub.ChangeMaxNotConatctDay;
/*     */ import com.newcrm.webapi.sub.QisoukeActiveCode;
/*     */ import com.newcrm.webapi.sub.QisoukeSetAuthUser;
/*     */ import com.newcrm.webapi.sub.RebuildLuceneIndex;
/*     */ import com.newcrm.webapi.sub.ShowRebuildLuceneIndexStatus;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import javax.servlet.RequestDispatcher;
/*     */ import javax.servlet.ServletConfig;
/*     */ import javax.servlet.ServletContext;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ 
/*     */ public class SystemSetting extends AbstractHttpServlet
/*     */ {
/*     */   private static final long serialVersionUID = -3300629610758456607L;
/*     */ 
/*     */   public void doGet(HttpServletRequest request, HttpServletResponse response)
/*     */     throws ServletException, IOException
/*     */   {
/*  56 */     if (!checkLogin(request)) {
/*  57 */       super.showLoginPage(request, response);
/*  58 */       return;
/*     */     }
/*     */ 
/*  62 */     if (!super.getLoginUser(request).isAdmin) {
/*  63 */       request.getRequestDispatcher("/nopermission.jsp").forward(
/*  64 */         request, response);
/*  65 */       return;
/*     */     }
/*     */ 
/*  68 */     String url = request.getRequestURI();
/*  69 */     String[] param = ParameterUtil.getParameters(url, getTagkey());
/*  70 */     if ((param == null) || (param.length == 0)) {
/*  71 */       User u = super.getLoginUser(request);
/*  72 */       CompanyExtManager manager = new CompanyExtManager();
/*     */ 
/*  75 */       String activeCode = manager.getFieldValue(u.companyId, 
/*  76 */         14);
/*  77 */       String checkCode = manager.getFieldValue(u.companyId, 
/*  78 */         16);
/*  79 */       String companyId2 = manager.getFieldValue(u.companyId, 
/*  80 */         15);
/*  81 */       String expiredDate = manager.getFieldValue(u.companyId, 
/*  82 */         18);
/*  83 */       String licenceNum = manager.getFieldValue(u.companyId, 
/*  84 */         17);
/*     */ 
/*  86 */       request.setAttribute("activeCode", activeCode);
/*  87 */       request.setAttribute("checkCode", checkCode);
/*  88 */       request.setAttribute("companyId2", companyId2);
/*  89 */       request.setAttribute("expiredDate", expiredDate);
/*  90 */       request.setAttribute("licenceNum", licenceNum);
/*     */ 
/*  92 */       String maxNotContactDay = manager.getFieldValue(u.companyId, 
/*  93 */         1);
/*  94 */       if ((maxNotContactDay == null) || 
/*  95 */         (maxNotContactDay.trim().length() == 0))
/*     */       {
/*  97 */         request.setAttribute("maxNotContactDay", 
/*  98 */           String.valueOf(0));
/*  99 */         request.setAttribute("categoryIds", 
/* 100 */           "*");
/*     */       } else {
/* 102 */         int days = 0;
/* 103 */         String categoryIds = "*";
/*     */ 
/* 106 */         int idx = maxNotContactDay.indexOf("_");
/* 107 */         if (idx > 0) {
/* 108 */           days = Util.str2Int(maxNotContactDay.substring(0, idx));
/* 109 */           categoryIds = maxNotContactDay.substring(idx + 1);
/*     */         } else {
/* 111 */           days = Util.str2Int(maxNotContactDay);
/*     */         }
/* 113 */         request.setAttribute("maxNotContactDay", String.valueOf(days));
/* 114 */         request.setAttribute("categoryIds", categoryIds);
/*     */       }
/*     */ 
/* 118 */       LuceneManager luceneManager = 
/* 119 */         LuceneManager.getInstance(getServletConfig().getServletContext()
/* 120 */         .getRealPath("lucene/"));
/*     */ 
/* 122 */       request.setAttribute("indexStatus", 
/* 123 */         luceneManager.getRunningStatus() ? "1" : "0");
/*     */ 
/* 125 */       request.getRequestDispatcher("/system_setting.jsp").forward(
/* 126 */         request, response);
/* 127 */       return;
/*     */     }
/*     */     try
/*     */     {
/* 131 */       if (param.length == 1)
/*     */       {
/* 133 */         if ("activeCode".equals(param[0])) {
/* 134 */           new QisoukeActiveCode(this).parse(request, response);
/* 135 */           return;
/*     */         }
/*     */ 
/* 139 */         if ("setAuthUser".equals(param[0])) {
/* 140 */           new QisoukeSetAuthUser(this).parse(request, response);
/* 141 */           return;
/*     */         }
/*     */ 
/* 145 */         if ("activeCodeRedo".equals(param[0])) {
/* 146 */           new ActiveCodeChecker(this, true).parse(request, response);
/* 147 */           return;
/*     */         }
/*     */ 
/* 151 */         if ("setPublicReadOnly".equals(param[0])) {
/* 152 */           User u = super.getLoginUser(request);
/*     */ 
/* 154 */           String readOnlyFlag = Util.getURLParameter(request
/* 155 */             .getParameter("readOnlyFlag"));
/*     */ 
/* 157 */           CompanyExtManager manager = new CompanyExtManager();
/* 158 */           int result = manager.update(
/* 159 */             13, readOnlyFlag, 
/* 160 */             u.companyId, u.userId);
/*     */ 
/* 162 */           if (result != 1) {
/* 163 */             super.showErrorMessage(response, "公海客户只读设置存入失败!");
/* 164 */             return;
/*     */           }
/*     */ 
/* 167 */           CompanyInfo company = super.getCompany(u.companyId);
/* 168 */           company.setPublicReadOnlyFlag = readOnlyFlag;
/*     */ 
/* 170 */           response.setContentType("text/html;charset=utf-8");
/* 171 */           PrintWriter out = response.getWriter();
/* 172 */           JSONObject jsonObject = new JSONObject();
/* 173 */           jsonObject.put("error", "0");
/* 174 */           jsonObject.put("msg", "公海客户只读设置存入成功！");
/* 175 */           out.println(jsonObject);
/* 176 */           out.flush();
/* 177 */           out.close();
/* 178 */           return;
/*     */         }
/*     */ 
/* 182 */         if ("closeGroupData".equals(param[0])) {
/* 183 */           User u = super.getLoginUser(request);
/*     */ 
/* 185 */           String closeFlag = Util.getURLParameter(request
/* 186 */             .getParameter("closeFlag"));
/*     */ 
/* 188 */           CompanyExtManager manager = new CompanyExtManager();
/* 189 */           int result = manager.update(
/* 190 */             12, 
/* 191 */             closeFlag, u.companyId, u.userId);
/*     */ 
/* 193 */           if (result != 1) {
/* 194 */             super.showErrorMessage(response, "部门公海设置存入失败!");
/* 195 */             return;
/*     */           }
/*     */ 
/* 199 */           CustomerManager customerManager = new CustomerManager();
/* 200 */           customerManager.moveToCompanyPublicDate(u.companyId);
/*     */ 
/* 202 */           CompanyInfo company = super.getCompany(u.companyId);
/* 203 */           company.closeGroupPublicDataFlag = closeFlag;
/*     */ 
/* 205 */           response.setContentType("text/html;charset=utf-8");
/* 206 */           PrintWriter out = response.getWriter();
/* 207 */           JSONObject jsonObject = new JSONObject();
/* 208 */           jsonObject.put("error", "0");
/* 209 */           jsonObject.put("msg", "部门公海设置存入成功！");
/* 210 */           out.println(jsonObject);
/* 211 */           out.flush();
/* 212 */           out.close();
/* 213 */           return;
/*     */         }
/*     */ 
/* 217 */         if ("allowGroup".equals(param[0])) {
/* 218 */           User u = super.getLoginUser(request);
/*     */ 
/* 220 */           String groupIds = Util.getURLParameter(request
/* 221 */             .getParameter("groupIds"));
/*     */ 
/* 223 */           CompanyExtManager manager = new CompanyExtManager();
/* 224 */           int result = manager.update(
/* 225 */             11, groupIds, 
/* 226 */             u.companyId, u.userId);
/*     */ 
/* 228 */           if (result != 1) {
/* 229 */             super.showErrorMessage(response, "公共数据保护数据存入失败!");
/* 230 */             return;
/*     */           }
/*     */ 
/* 233 */           CompanyInfo company = super.getCompany(u.companyId);
/* 234 */           company.allowPublicGroupList = groupIds;
/*     */ 
/* 236 */           response.setContentType("text/html;charset=utf-8");
/* 237 */           PrintWriter out = response.getWriter();
/* 238 */           JSONObject jsonObject = new JSONObject();
/* 239 */           jsonObject.put("error", "0");
/* 240 */           jsonObject.put("msg", "公共数据保护数据存入成功！");
/* 241 */           out.println(jsonObject);
/* 242 */           out.flush();
/* 243 */           out.close();
/* 244 */           return;
/*     */         }
/*     */ 
/* 248 */         if ("changeMaxNotConatctDay".equals(param[0])) {
/* 249 */           new ChangeMaxNotConatctDay(this).parse(request, response);
/* 250 */           return;
/*     */         }
/*     */ 
/* 254 */         if ("rebuildIndex".equals(param[0])) {
/* 255 */           String path = getServletConfig().getServletContext()
/* 256 */             .getRealPath("lucene/");
/* 257 */           new RebuildLuceneIndex(this, path).parse(request, response);
/* 258 */           return;
/*     */         }
/*     */ 
/* 262 */         if ("rebuildIndexStatus".equals(param[0])) {
/* 263 */           String path = getServletConfig().getServletContext()
/* 264 */             .getRealPath("lucene/");
/* 265 */           new ShowRebuildLuceneIndexStatus(this, path).parse(request, 
/* 266 */             response);
/* 267 */           return;
/*     */         }
/*     */       }
/*     */     }
/*     */     catch (NotFoundException e)
/*     */     {
/* 273 */       request.getRequestDispatcher("/errorpage.jsp").forward(request, 
/* 274 */         response);
/* 275 */       return;
/*     */     }
/* 277 */     super.doGet(request, response);
/*     */   }
/*     */ 
/*     */   protected AbstractAction getAddAction()
/*     */   {
/* 282 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getDeleteAction(String id)
/*     */   {
/* 287 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getListAction()
/*     */   {
/* 292 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getShowAction(String id)
/*     */   {
/* 297 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getShowAddPageAction()
/*     */   {
/* 302 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getShowConfirmDestroyAction(String id)
/*     */   {
/* 307 */     return null;
/*     */   }
/*     */ 
/*     */   protected AbstractAction getShowUpdatePageAction(String id)
/*     */   {
/* 312 */     return null;
/*     */   }
/*     */ 
/*     */   protected String getTagkey()
/*     */   {
/* 317 */     return "/systemSetting";
/*     */   }
/*     */ 
/*     */   protected AbstractAction getUpdateAction(String id)
/*     */   {
/* 322 */     return null;
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.SystemSetting
 * JD-Core Version:    0.6.1
 */